/*
 * @Author: Arcanum
 * @Copyright: 2010 by Mastercoding.NET
 * @Date: 22. July 2010
 * @File: splash.cpp
 */

#include "TGALoader.h"



CTGATexture mcnet;
CTGATexture splash2;

float sp2_time = 0;
int splashloaded = 0;

void mcLoadSplashTex(void)
{
    char mcnet2[16] = "src/misc/mc.tga";
    char mcnet3[20] = "src/misc/splash.tga";

    if(!mcnet.LoadTGA(mcnet2))
    {
        mcError("Error: Failed to load mc.tga");
    }
    mcnet.Swizzle();

    if(!splash2.LoadTGA(mcnet3))
    {
        mcError("Error: Failed to load splash.tga");
    }
    splash2.Swizzle();
    splashloaded = 1;
}

void mcShowSplashes(void)
{
    sceGumTranslate(&translate);


    if(translate.z > 0)
    {
        sceGuTexImage(0, 515, 272, 480, mcnet.Image());
        sceGumDrawArray(GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,
                    4, 0, splash1);

        if(translate.z-(0.9f*dt) < 0)
        {
            translate.z = 0;
            sceKernelDelayThread(1000000);
        } else
            translate.z -= 0.9f*dt;
    } else {
        sceGuTexImage(0, 515, 272, 480, splash2.Image());
        sceGumDrawArray(GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,
                    4, 0, splash1);

        sp2_time += 0.01f;
        if(sp2_time > 1)
        {
            step = 2;
            sceKernelDelayThread(800000);
        }
    }
}